package com.tvsinfo.jdk.demo.case2_function_interface;

import java.util.function.Function;
import java.util.function.Predicate;

public class PredicateDemo {


    public static void main(String[] args) {
        PredicateDemo predicateDemo = new PredicateDemo();
        predicateDemo.predicate();

    }


    public void predicate() {

        Predicate<Integer> predicate = o -> o > 50;
        this.test(predicate);

        System.out.println("\n\r" + "--------------------------------------------");
        this.test(integer -> integer % 2 == 0);
        System.out.println("\n\r" + "--------------------------------------------");
        Function<Integer, Integer> function = Math::abs;
        this.test(integer -> integer % 4 == 0);
    }

    public void test(Predicate<Integer> predicate) {
        for (int i = 0; i < 100; i++) {
            boolean b = predicate.test(i);
            if (b) {
                System.out.print(i + ",   ");
            }
        }
    }


}
